var url = window.top.location.href;

// querystring wrapper
function queryStr(ji) {
    hu = window.top.location.search.substring(1);
    gy = hu.split("&");
    for (i=0;i<gy.length;i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
}

// move to the next step, passing oauth_verifier
sendMessage({'type':'auth2','verifier': queryStr('oauth_verifier')});


// second step auth
function sendMessage(message) {
  chrome.extension.sendRequest(message, function(response) {
    console.log(response);
    window.top.close();
  });
}
